//
//  ShareBtnView.m
//  StarBuyer
//
//  Created by 钟游 on 2019/8/25.
//  Copyright © 2019年 bigbo. All rights reserved.
//

#import "ShareBtnView.h"

@implementation ShareBtnView
-(instancetype)initWithFrame:(CGRect)frame{
    if (self=[super initWithFrame:frame]) {
        [self createUI];
    }
    return self;
}
-(void)clickSender:(UIButton*)sender{

    if (sender.tag==100) {
        if (_delegate && [_delegate respondsToSelector:@selector(savePhoto)]) {
            [_delegate savePhoto];
        }

    }else{
        if (_delegate && [_delegate respondsToSelector:@selector(shareThird)]) {
            [_delegate shareThird];
        }
    }
}
#pragma mark -- UI
-(void)createUI{
    NSArray * titleArray =@[@"保存到相册",@"分享"];
    for (int i = 0; i<titleArray.count; i++) {
        UIButton * btn=[UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame = CGRectMake(i*KscreenWidth/2, 0, KscreenWidth/2, CGRectGetHeight(self.frame));
        [btn setTitle:titleArray[i] forState:UIControlStateNormal];
        btn.titleLabel.font=[UIFont systemFontOfSize:18];
        btn.tag = 100 +i;
        [btn addTarget: self action:@selector(clickSender:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:btn];
    }
    UIView * line =[[UIView alloc]initWithFrame:CGRectMake(KscreenWidth/2-.25, 0, .5, CGRectGetHeight(self.frame))];
    line.backgroundColor=[UIColor grayColor];
    [self addSubview:line];
}


@end
